<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        // 借用构造函数继承 + 原型对象的深拷贝

        function Dog(name, age) {
            this.name = name;
            this.age = age;
            this.type = '狗';
        }

        Dog.prototype.say = function () {
            console.log('汪');
        }



        function KeJi(name, age, color) {

            Dog.call(this , name , age) ;

            this.color = color;

        }


        // 实现父类prototype的深拷贝
        KeJi.prototype = {...Dog.prototype} ;   // 

        KeJi.prototype.speak = function() {
            console.log('hi');
        }

        const k = new KeJi('旺财' , 1 , '灰色') ;
        console.log(k);


        const d = new Dog('旺财' , 1 ) ;
        console.log(d);

    </script>

</body>

</html>